home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 16004 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.1 KB  |  46 lines

  1. Path: news.sfu.ca!mpohores
  2. From: mpohores@news.sfu.ca (Michael John Pohoreski)
  3. Newsgroups: comp.lang.c++
  4. Subject: int (*p)[4]; (Watcom problem)
  5. Date: 9 Apr 1996 01:02:59 GMT
  6. Organization: Simon Fraser University
  7. Message-ID: <4kcd03$37j@morgoth.sfu.ca>
  8. NNTP-Posting-Host: fraser.sfu.ca
  9. Summary: How do I use this defn. of pointer to array?
  10. Keywords: WATCOM C++ POINTER ARRAY PROBLEM
  11. X-Newsreader: NN version 6.5.0 #5 (NOV)
  12.  
  13. I came across (ARM, page 97) the following way to define
  14. a pointer to an array:
  15.    int (*p)[];
  16.  
  17. (Yes, I allready know I can just do: int *p)
  18. So I tried it in a small C++ test program: p2a.cpp
  19.  
  20. #include <stdio.h>
  21.  
  22. void main( void )
  23. {
  24.   int a[4] = { -13, 11, -7, 5 };
  25.   int (*x)[4]; // pointer to array
  26.  
  27.   for (int i = 0; i < 4; i++ )
  28.   {
  29.     (int *)x = &a[i];
  30.     printf( "%d\n", (*x)[0] );
  31.   }
  32. }
  33.  
  34. Now here's my problem:
  35.  Under Watcom 10.5, the above doesn't compile with wcl386
  36. but it compiles under DJGPP 2.0, and Borland C++ 3.1  Anyone know why?
  37.  
  38.  Is this a bug?
  39.  
  40. Please email.
  41.  
  42. (ARM is The C++ Annotated Reference Manual)
  43. --
  44. mpohores@sfu.ca
  45. Only in Canada, are traitors called separatists.
  46.